package com.shujia.this_;

/*
① 默认初始化
② 定义属性的同时赋值
③ 构造器中初始化
④ 通过“对象.属性“或“对象.方法”的方式赋值
① - ② - ③ - ④
 */
public class Student {
    // 默认初始化
    String name;

    // 定义属性的同时赋值
    int age = 20;

    public Student() {
    }

    public Student(String name, int age) {
        // 构造器中初始化
        this.name = name;
        this.age = age;
    }

    public static void main(String[] args) {
        Student student = new Student();
        // 通过“对象.属性“或
        student.name = "zs";

        // “对象.方法”的方式赋值
//        student.setAge(11);

        System.out.println(student.name);
        System.out.println(student.age);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
